package top.rzhsky.util;

import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.layout.HBox;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.util.Callback;

/**
 * @author rzh
 * time: 2018-11-22 15:05
 * 设置聊天信息列表
 */
public class MyCallBack implements Callback<ListView<String>, ListCell<String>> {
    @Override
    public ListCell<String> call(ListView<String> param) {
        return new ListCell<String>() {
            @Override
            protected void updateItem(String str, boolean empty) {
                super.updateItem(str, empty);
                setGraphic(null);
                setText(null);
                if (str != null) {
                    HBox hBox = new HBox();
                    Text name = new Text(str);
                    name.setFont(new Font(18));

                    hBox.getChildren().addAll(name);
                    setGraphic(hBox);
                }
            }
        };
    }
}
